cssimage: Fix gradient start/end computation
authorBenjamin Otte <otte@redhat.com>
Sat, 6 Oct 2012 19:54:10 +0000 (15:54 -0400)
committerBenjamin Otte <otte@redhat.com>
Sat, 6 Oct 2012 19:56:08 +0000 (15:56 -0400)
This computation is only supposed to happen for repeating gradients, not
for all of them.

gtk/gtkcssimagelinear.c

index bd80d5f8353c156afd7bd78cea8119cc6bb324c5..b09131d4233ea37c8579f74e73edc4a393934ba8 100644 (file)
@@ -40,28 +40,36 @@ gtk_css_image_linear_get_start_end (GtkCssImageLinear *linear,
   double pos;
   guint i;
       
-  stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, 0);
-  if (stop->offset == NULL)
-    *start = 0;
-  else
-    *start = _gtk_css_number_value_get (stop->offset, length) / length;
-
-  *end = *start;
-
-  for (i = 0; i < linear->stops->len; i++)
+  if (linear->repeating)
     {
-      stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
-      
+      stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, 0);
       if (stop->offset == NULL)
-        continue;
+        *start = 0;
+      else
+        *start = _gtk_css_number_value_get (stop->offset, length) / length;
 
-      pos = _gtk_css_number_value_get (stop->offset, length) / length;
+      *end = *start;
 
-      *end = MAX (pos, *end);
+      for (i = 0; i < linear->stops->len; i++)
+        {
+          stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
+          
+          if (stop->offset == NULL)
+            continue;
+
+          pos = _gtk_css_number_value_get (stop->offset, length) / length;
+
+          *end = MAX (pos, *end);
+        }
+      
+      if (stop->offset == NULL)
+        *end = MAX (*end, 1.0);
+    }
+  else
+    {
+      *start = 0;
+      *end = 1;
     }
-  
-  if (stop->offset == NULL)
-    *end = MAX (*end, 1.0);
 }
 
 static void